OPC Studio User's Guide and Reference
ReadMultipleItemValues(IEasyDAClient,DAReadItemArguments[]) Method
Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class > ReadMultipleItemValues Method : ReadMultipleItemValues(IEasyDAClient,DAReadItemArguments[]) Method
The client object that will perform the operation.

This is typically the EasyDAClient object.

The value of this parameter cannot be null (Nothing in Visual Basic).

Array of arguments, one element per each OPC item involved in the operation.

The value of this parameter cannot be null (Nothing in Visual Basic).

The individual elements of the parameter value cannot be null (Nothing in Visual Basic).

Reads multiple named item values from a single OPC server, using array of argument objects as an input.
Syntax
'Declaration
 
<ExtensionAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function ReadMultipleItemValues( _
   ByVal client As IEasyDAClient, _
   ByVal argumentsArray() As DAReadItemArguments _
) As ValueResult()
'Usage
 
Dim client As IEasyDAClient
Dim argumentsArray() As DAReadItemArguments
Dim value() As ValueResult
 
value = IEasyDAClientExtension.ReadMultipleItemValues(client, argumentsArray)
[Extension()]
[NotNull()]
public static ValueResult[] ReadMultipleItemValues( 
   IEasyDAClient client,
   DAReadItemArguments[] argumentsArray
)
[Extension()]
[NotNull()]
public:
static array<ValueResult^>^ ReadMultipleItemValues( 
   IEasyDAClient^ client,
   array<DAReadItemArguments^>^ argumentsArray
) 

Parameters

client
The client object that will perform the operation.

This is typically the EasyDAClient object.

The value of this parameter cannot be null (Nothing in Visual Basic).

argumentsArray
Array of arguments, one element per each OPC item involved in the operation.

The value of this parameter cannot be null (Nothing in Visual Basic).

The individual elements of the parameter value cannot be null (Nothing in Visual Basic).

Return Value

The function returns an array of OpcLabs.BaseLib.OperationModel.ValueResult objects. The indices of elements in the output array are the same as those in the input array, argumentsArray.

This method never returns null (Nothing in Visual Basic).

The individual elements of the returned value are never null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks
The size of the input array will become the size of the output array. The element positions (indices) in the output array are the same as in the input array.

This is an extension method (info: C#, VB.NET). In languages that have support for extensions methods (such as C# and VB.NET), you can use the extension method as if it were a regular method on the object that is its first parameter. In other languages (such as with Python.NET), you will call the extension as a static method, and pass it the object on which it acts as its first parameter.

Example
// This example shows how to read values of 4 items at once, and display them.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using System.Diagnostics;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.DataAccess;

namespace DocExamples.DataAccess._EasyDAClient
{
    class ReadMultipleItemValues
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ValueResult[] valueResults = client.ReadMultipleItemValues("OPCLabs.KitServer.2",
                new DAItemDescriptor[]
                {
                    "Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"
                });

            for (int i = 0; i < valueResults.Length; i++)
            {
                ValueResult valueResult = valueResults[i];
                Debug.Assert(!(valueResult is null));

                if (valueResult.Succeeded)
                    Console.WriteLine($"valueResults[{i}].Value: {valueResult.Value}");
                else
                    Console.WriteLine($"valueResults[{i}] *** Failure: {valueResult.ErrorMessageBrief}");
            }
        }


        // Example output:
        //
        //valueResults[0].Value: 0.00125125888851588
        //valueResults[1].Value: 0.732510924339294
        //valueResults[2].Value: -0.993968485238202
        //valueResults[3].Value: 0
    }
}
# This example shows how to read values of 4 items at once, and display them.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

$valueResults = [IEasyDAClientExtension]::ReadMultipleItemValues($client, 
    "OPCLabs.KitServer.2", @(
        (New-Object DAItemDescriptor("Simulation.Random")),
        (New-Object DAItemDescriptor("Trends.Ramp (1 min)")),
        (New-Object DAItemDescriptor("Trends.Sine (1 min)")),
        (New-Object DAItemDescriptor("Simulation.Register_I4"))
        ))

for ($i = 0; $i -lt $valueResults.Length; $i++) {
    $valueResult = $valueResults[$i]
    if ($valueResult.Succeeded) {
        Write-Host "valueResults($($i)).Value: $($valueResult.Value)"
    }
    else {
        Write-Host "valueResults($($i)) *** Failure: $($valueResult.ErrorMessageBrief)"
    }
}


# Example output:
#
#valueResults(0).Value: 0.00125125888851588
#valueResults(1).Value: 0.732510924339294
#valueResults(2).Value: -0.993968485238202
#valueResults(3).Value: 0
' This example shows how to read values of 4 items at once, and display them.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.DataAccess

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadMultipleItemValues
        Public Shared Sub Main1()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            Dim valueResults() As ValueResult = client.ReadMultipleItemValues("OPCLabs.KitServer.2",
                New DAItemDescriptor() {"Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4"})

            For i = 0 To valueResults.Length - 1
                Dim valueResult As ValueResult = valueResults(i)
                Debug.Assert(valueResult IsNot Nothing)

                If valueResult.Succeeded Then
                    Console.WriteLine($"valueResults[{i}].Value: {valueResult.Value}")
                Else
                    Console.WriteLine($"valueResults[{i}] *** Failure: {valueResult.ErrorMessageBrief}")
                End If
            Next i
        End Sub

        ' Example output:
        '
        'valueResults[0].Value: 0.00125125888851588
        'valueResults[1].Value: 0.732510924339294
        'valueResults[2].Value: -0.993968485238202
        'valueResults[3].Value: 0
    End Class
End Namespace
# This example shows how to read values of 4 items at once, and display them.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

#
valueResultArray = IEasyDAClientExtension.ReadMultipleItemValues(client, [
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Random')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Ramp (1 min)')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Trends.Sine (1 min)')),
    DAReadItemArguments(ServerDescriptor('OPCLabs.KitServer.2'), DAItemDescriptor('Simulation.Register_I4')),
    ])

for i, valueResult in enumerate(valueResultArray):
    assert valueResult is not None
    if valueResult.Succeeded:
        print('valueResultArray[', i, '].Value: ', valueResult.Value, sep='')
    else:
        print('valueResultArray[', i, '] *** Failure: ', valueResult.ErrorMessageBrief, sep='')
// This example shows how to read values of 4 items at once, and display them.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using System.Diagnostics;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.DataAccess;

namespace DocExamples.DataAccess.Xml
{
    class ReadMultipleItemValues
    {
        public static void Main1Xml()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ValueResult[] valueResults = client.ReadMultipleItemValues("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx",
                new DAItemDescriptor[]
                {
                    "Dynamic/Analog Types/Double", "Dynamic/Analog Types/Double[]", "Dynamic/Analog Types/Int", "Static/Analog Types/Int"
                });

            for (int i = 0; i < valueResults.Length; i++)
            {
                ValueResult valueResult = valueResults[i];
                Debug.Assert(!(valueResult is null));

                if (valueResult.Succeeded)
                    Console.WriteLine($"valueResults[{i}].Value: {valueResult.Value}");
                else
                    Console.WriteLine($"valueResults[{i}] *** Failure: {valueResult.ErrorMessageBrief}");
            }
        }


        // Example output:
        //
        //valueResults[0].Value: 50
        //valueResults[1].Value: System.Double[]
        //valueResults[2].Value: 100
        //valueResults[3].Value: 12345
    }
}
' This example shows how to read values of 4 items at once, and display them.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.DataAccess

Namespace DataAccess.Xml
    Partial Friend Class ReadMultipleItemValues
        Public Shared Sub Main1Xml()
            ' Instantiate the client object.
            Dim client = New EasyDAClient()

            Dim valueResults() As ValueResult = client.ReadMultipleItemValues("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx",
                New DAItemDescriptor() {"Dynamic/Analog Types/Double", "Dynamic/Analog Types/Double[]", "Dynamic/Analog Types/Int", "Static/Analog Types/Int"})

            For i = 0 To valueResults.Length - 1
                Dim valueResult As ValueResult = valueResults(i)
                Debug.Assert(valueResult IsNot Nothing)

                If valueResult.Succeeded Then
                    Console.WriteLine($"valueResults[{i}].Value: {valueResult.Value}")
                Else
                    Console.WriteLine($"valueResults[{i}] *** Failure: {valueResult.ErrorMessageBrief}")
                End If
            Next i
        End Sub

        ' Example output:
        '
        'valueResults[0].Value: 50
        'valueResults[1].Value System.Double[]
        'valueResults[2].Value: 100
        'valueResults[3].Value: 12345

    End Class
End Namespace
# This example shows how to read values of 4 items at once, and display them.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyDAClient()

valueResults = IEasyDAClientExtension.ReadMultipleItemValues(client,
    ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'),
    [
        DAItemDescriptor('Dynamic/Analog Types/Double'),
        DAItemDescriptor('Dynamic/Analog Types/Double[]'),
        DAItemDescriptor('Dynamic/Analog Types/Int'),
        DAItemDescriptor('Static/Analog Types/Int')
    ])

for i, valueResult in enumerate(valueResults):
    assert valueResult is not None
    if valueResult.Succeeded:
        print('valueResults[', i, '].Value: ', valueResult.Value, sep='')
    else:
        print('valueResults[', i, '] *** Failure: ', valueResult.ErrorMessageBrief, sep='')


# Example output:
#
#valueResults[0].Value: 0.00125125888851588
#valueResults[1].Value: System.Double[]
#valueResults[2].Value: -0.993968485238202
#valueResults[3].Value: 0
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also